﻿/* 
| - - Motion.Euzo.Ca - - - Motion and M+ from euzo.ca - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
*/

// Extends the functionality of the document object, adds additional functions such as calculating the exact position of an
// item on the screen, etc.

(function ()
{
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *    
    // Detect if the browser is Google Chrome, and return true if it is, otherwise return false.
    document.IsGoogleChrome = function ()
    {
        return navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
    }

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *    
    // Calculate the exact position of an element from the beginning of the page.
    document.FindElementLocation = function (Element)
    {
        var TopCorner = 0;
        var LeftCorner = 0;
        while (Element)
        {
            TopCorner += Element.offsetTop;
            LeftCorner += Element.offsetLeft;
            Element = Element.offsetParent
        }
        return [TopCorner, LeftCorner];
    }

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *    
    // Calculate the exact position of an element from the beginning of the page (the top corner)
    document.FindElementLocationTop = function (Element)
    {
        var TopCorner = 0;
        while (Element)
        {
            TopCorner += Element.offsetTop;
            Element = Element.offsetParent
        }
        return TopCorner;
    }

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *    
    // Calculate the exact position of an element from the beginning of the page (the left corner).
    document.FindElementLocationLeft = function (Element)
    {
        var LeftCorner = 0;
        while (Element)
        {
            LeftCorner += Element.offsetLeft;
            Element = Element.offsetParent
        }
        return LeftCorner;
    }

})();
